import os


from dotenv import load_dotenv
load_dotenv()

from langchain import hub
from langchain.agents import AgentExecutor, create_react_agent
from langchain_community.tools.tavily_search import TavilySearchResults
from langchain_openai import OpenAI


from langchain_community.utilities import SerpAPIWrapper
from langchain.tools import Tool
tools = [TavilySearchResults(max_results=1)]

prompt = hub.pull("hwchase17/react")

# 选择要使用的LLM
llm = OpenAI()

# 构建ReAct agent
agent = create_react_agent(llm, tools, prompt)


# 通过传入agent和tools来创建一个agent executor
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)


agent_executor.invoke({"input": "LangChain是什么?"})



